#coding=utf-8
__author__ = 'liubin'
import email.utils
from email.mime.text import MIMEText
import smtplib

msg = MIMEText("Hello, this is a test!")
msg["From"] = email.utils.formataddr(("Author", "author@example.com"))
msg["To"] = email.utils.formataddr(("Recipient", "recipient@example.com"))
msg["Subject"] = "Simple test"

server = smtplib.SMTP("192.168.1.149", 25)
server.set_debuglevel(True)    #用来显示如何和服务器交互

try:
    server.sendmail("author@example.com", ["recipient@example.com"], msg.as_string())
finally:
    server.quit()